//
//  VCOrderDetail.m
//  express
//
//  Created by mac1 on 15/9/10.
//  Copyright (c) 2015年 longchen. All rights reserved.
//


#import "VCOrderDetail.h"

#import "ZTTableView.h"

#import "CellODBottom.h"

@interface VCOrderDetail ()

@property (nonatomic, strong) ZTTableView * tableViewOut;

@end

@implementation VCOrderDetail

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor redColor];
    
    [self addNavigation];
    
    [self addTableViewOutside];
    // Do any additional setup after loading the view.
    
}


-(void)addTableViewOutside
{

    self.tableViewOut = [[ZTTableView alloc]initWithFrame:self.view.frame withStyle:UITableViewStylePlain];

    [self.view addSubview:self.tableViewOut];
    
    //判断tableView的手势  如果向上，直接划到第二格
     //选中某一行后想要tableView自动滚动使得选中行始终处于table的top、middle或者bottom，使用以下方法中的一个就可以实现：
    [self.tableViewOut scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES];

    self.tableViewOut.showsVerticalScrollIndicator = NO;

    self.tableViewOut.separatorStyle = UITableViewCellSeparatorStyleNone;

    [self.tableViewOut setHeightForRowAtIndexPath:^CGFloat(NSIndexPath *indexPath) {
        return 240;
    }];

    [self.tableViewOut setNumberOfRowsInSection:^NSInteger(NSInteger section) {
        return 5;
    }];

    [self.tableViewOut setCustomizeCell:^UITableViewCell *(UITableView *tableView, NSIndexPath *indexPath) {
        
        UITableViewCell * cell;
        
        if(indexPath.row == 0)
        {

            cell  = [ [ [ UINib nibWithNibName : @"XibODTop" bundle : nil ] instantiateWithOwner : nil options : nil ]objectAtIndex:0];
            
            [tableView registerNib:[UINib nibWithNibName : @"XibODTop" bundle : nil ] forCellReuseIdentifier : @"pool" ];
            
            cell.selectionStyle = UITableViewCellSelectionStyleNone;

        }
        else    //(indexPath.row == 1)
        {

            cell = [[CellODBottom alloc]initWithVC:self];
            
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }
        
        return cell;
    }];

}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma  mark 导航栏
-(void)addNavigation
{

    [self.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:2/255.0 green:147/255.0 blue:95/255.0 alpha:1]];

    //创建 标题LABEL
    UILabel * titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, 60, 140, 20)];
    
    titleLabel.text = @"订单详情";
    
    titleLabel.textAlignment = NSTextAlignmentCenter;
    
    titleLabel.font = [UIFont systemFontOfSize:14];
    
    titleLabel.font = [UIFont boldSystemFontOfSize:20];//加粗

    titleLabel.textColor = [UIColor whiteColor];

    self.navigationItem.titleView = titleLabel;


    //创建左侧按钮,这样写代码重用性较高
    UIButton *leftButton  = [ UIButton  buttonWithType : UIButtonTypeSystem ];

    leftButton.frame = CGRectMake(0, 0, 30, 30);

    [leftButton setImage:[UIImage imageNamed:@"back.png"] forState:UIControlStateNormal];

    [leftButton addTarget:self action:@selector(leftBtnClick:) forControlEvents:UIControlEventTouchUpInside];

    UIBarButtonItem *leftBarBtn = [[UIBarButtonItem alloc]initWithCustomView:leftButton];

    self.navigationItem.leftBarButtonItem = leftBarBtn;

}


-(void)leftBtnClick:(UIButton*)btnClick
{

    [self.navigationController popViewControllerAnimated:YES];

}


@end
